package com.jzy.gulimall.product.web;

import com.jzy.gulimall.product.service.SkuInfoService;
import com.jzy.gulimall.product.vo.item.SkuItemVo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;
import java.util.concurrent.ExecutionException;

/**
 * @author jzy
 * @date 2020/9/15 21:16
 */
@Controller
public class ItemController {

    @Resource
    private SkuInfoService skuInfoService;

    /**
     * 详情页 查询sku信息
     */
    @GetMapping({"/{skuId}.html", "/item.html/{skuId}.html"})
    public String itemPage(@PathVariable("skuId") Long skuId, Model model) throws ExecutionException, InterruptedException {
        SkuItemVo skuItemVo = skuInfoService.skuItemInfo(skuId);
        model.addAttribute("item", skuItemVo);
        return "item";
    }
}
